/**
 * Zfounder.com Inc.
 * Copyright (c) 2013-2066 All Rights Reserved.
 */
package com.superjson.showpro.shared.result;

import java.io.Serializable;

/**
 * Created By zby on 13:50 2019/6/21
 * 返回给前端的响应结果
 */
public class Result<T> implements Serializable {

    private static final long serialVersionUID = -6899890735340051326L;

    /**
     * 响应是否成功
     */
    private boolean success;

    /**
     * 返回错误的内容
     */
    private ErrorContext errorCtx;

    /**
     * 响应给前端的内容
     */
    private T resultData;

    public Result() {
    }

    public Result(boolean success) {
        this.success = success;
    }

    public Result(boolean success, T resultData) {
        this.success = success;
        this.resultData = resultData;
    }

    /**
     * 错误编码参考{@link com.superjson.showpro.shared.result.ResultCodeEnum}
     *
     * @param success
     * @param errorCode
     * @param errorMsg
     */
    public Result(boolean success, String errorCode, String errorMsg) {
        this.success = success;
        this.errorCtx = new ErrorContext(errorCode, errorMsg);
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public ErrorContext getErrorCtx() {
        return errorCtx;
    }

    public void setErrorCtx(ErrorContext errorCtx) {
        this.errorCtx = errorCtx;
    }

    public T getResultData() {
        return resultData;
    }

    public void setResultData(T resultData) {
        this.resultData = resultData;
    }


}
